
function sendRequest() {
		$.post("http://localhost:8080/Prodavalnik/LoginServlet", {'name':$("#username").val(),
				'password':$("#password").val(),'check':document.getElementById("remember").checked},
				function(data){
				if(data==$("#username").val()){
				$('#navbar-collapse').empty().html("<div class = \"navbar-collapse collapse\" ><ul class=\"nav navbar-nav navbar-right\">"+
				"<li><a role=\"button\" href=\"profile-settings.html\"><i class=\"glyphicon glyphicon-user\"></i> Profile</a>"+
					"</li><li><a  onclick=\"Logout()\"><i class=\"glyphicon glyphicon-lock\"></i> Logout</a></li> </ul></div>"
				)}
				else{
					window.location.replace("errorLoginPage.html");
				}	

				;}/* END OF .html */
			);/*  END of POST request*/
		}/*END of SEND REQUEST*/

function GettoHomePage(){
	
				window.location.replace("copyOfpage1.html");
}/*End of gettohomepage*/

function ProfileFunction(){
	$.post("http://localhost:8080/Prodavalnik/ProfileServlet",
	function(data){
		if(data == "error"){
			alert('You\'re not logged in!');
			GettoHomePage();
		}
		var values=data.split(',');	
		$("#home").replaceWith("<div align=\"right\"><h2 align=\"center\">User info</h2><div align=\"center\"><br><br> Email: <p>"+values[0]+"</p>Address : <p>"+values[1]+"</p>Phone: <p>"+values[2]+"</p></div></div>");
	}
); /*End of post*/
} /*End of ProfileFunction */


		function sendRegistration(){
			$.post("http://localhost:8080/Prodavalnik/RegistrationLogin", {'name':$("#username-reg").val(), 'password':$("#password-reg").val(),
					'address':$("#address-reg").val(), 'phone':$("#phone-reg").val(), 'email':$("#email-reg").val()},
				function(data){
					var x=window.confirm(data)
						if (x)
							location.reload();
						else
							$("modal-body")[0].reset();
					}/* END of function(data) */
				);/*  END of POST request */
			}/* END of SEND Registration*/
						
		
	function changeProfile(){
		$.post("http://localhost:8080/Prodavalnik/ChangeProfileServlet",
				{'email':$("#email").val(),'address':$("#address").val(),
					'phone':$("#phone").val(),'password':$("#password").val(),
					'repeatPass':$("#password2").val()
				},
				function(data){
					if(data=='error'){
						alert('You\'re not logged in!');
						GettoHomePage();
					}
					if(data=='false'){
						alert('Password don\'t match');
						location.reload();
					}
					else{
						alert(data);
					     window.location.replace("profile-settings.html");
				}
					
						
				}
		);/* END OF POST */		
	}	/*END OF CHANGEPROFILE */
		
	function getActivity(){
		$.post("http://localhost:8080/Prodavalnik/ActivityServlet",
				function(data){
				var values = data.split(',');
				$("#Sales").append("<p align=\"right\">"+values[0]+"</p>");
				$("#Bought").append("<p align=\"right\">"+values[1]+"</p>");
				$("#Liked").append("<p align=\"right\">"+values[2]+"</p>");
				$("#usernameHeader").append("<h3>"+values[3]+"</h3>");
			} /* end of function(data) */
		)/* End of post */		
	} /*End of getActivity() */

